<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
	<meta name="viewport" content="user-scalable=no,viewport-fit=cover" />
	<link href="./css/baseCss.css" rel="stylesheet" type="text/css"/>
	<link href="./base/layer.css" rel="stylesheet" type="text/css"/>
	<!-- <link href="./base/articlecon.css" rel="stylesheet" type="text/css"/> -->
	<link href="./base/base2.css" rel="stylesheet" type="text/css"/>
	<link rel="stylesheet" type="text/css" href="./css/swiper-3.4.0.min.css">
	<script type="text/javascript" src="./base/rem.js"></script>
	<script type="text/javascript" src="./base/iscroll.js"></script>

	<style type="text/css">
		section{
			padding: 0.3rem 0.5rem;
		}
		/*订单详情头部*/
		.orderDetail_state{
			background-color: #fff;
    		border-radius: 0.1rem;
    		margin-bottom: 0.3rem;
    		font-size: 0.45rem;
    		color: #999999;
    		overflow: auto;
    		padding: 0.45rem 0.3rem;
		}
		
		/*订单详情具体*/
		.orderDetail{
			background-color: #fff;
			color: #333333;
			padding: 0 0.3rem;
			font-size: 0.45rem;
		}
		.orderDetail_common{
			padding: 0.5rem 0;
    		border-bottom: 0.02rem solid #f5f5f5;
    		overflow: auto;
		}
		.orderDetail_title{
			overflow: auto;
    		font-size: 0.55rem;
    		/*margin-bottom: 0.5rem;*/
		}
		.orderDetail_pull img{
			width: 0.4rem;
    		margin-left: 0.2rem;
		}
		.res_order li{
			text-align: center;
    		line-height: 0.8rem;
		}

		/*通用样式*/
		.textLeft{
			float: left;
		}
		.textRight{
			float: right;
		}
		.textBig{
			font-size: 0.5rem;
		}
		.textSmall{
			font-size: 0.4rem;
		}
		.textBlue{
			color: #009eee;
		}
		.textRed{
			color: #ff6160;
		}
		.textGrey{
			color: #999999;
		}
		.textBottom{
			margin-bottom: 0.2rem;
		}
		.orderImg img{
			width: 0.5rem;
    		margin-left: 0.4rem;
		}
		.showNo{
			display: none;
		}

	</style>
	<title>订单详情</title>
</head>
<body>
	<div>
		<header class="allHeader">
			<div class="headerReturn" onclick="disOrder();"><img class="imgBai" src="./img/nav_bake.png"></div>
			<span>订单详情</span>
			<!-- <div class="headerList"><img class="imgBai" src="./img/nav_menu.png"></div> -->
		</header>
		
		<section>
			<div class="orderDetail_state">
				<div class="textLeft">状态：<span class="textBig textBlue status">尽快送达</span></div>
				<div class="textRight">骑手<span class="lastState_name">***</span></div>
			</div>
			<div class="orderDetail">
				<div class="orderDetail_common">
					<div class="orderDetail_title">
						<div class="textLeft userName">张**</div>
						
					</div>
					
					<!-- <div id="lastEvaluateText" class="textSmall"></div> -->
				</div>
				<div class="orderDetail_common">
					<div class="textBottom" style="overflow: hidden;">
						<div class="textLeft">
							<span id="lastState">
								<span id="lastState_time">00:00</span>&nbsp骑手<span class="lastState_name">***</span>
							</span>
							<span class="textGrey">骑手：<span class="deliveryName">***</span></span>
						</div>
						<div class="orderImg textRight"><!-- <img src="./img/phone_01.png"> --></div>
					</div>
					<div id="showProgress" onclick="showProgressCl();"><span class="textBlue">展开进度</span><span class="orderDetail_pull"><img src="./img/pull_02.png"></span></div>
				</div>
				<div class="orderDetail_common">
					<div class="textBig textBottom"><span class="foodListNumber">0</span>件商品</div>
					<div><span class="textRed">备注：</span><span class="textGrey remark">少放辣椒，加一瓶矿泉水</span></div>
				</div>
				<div class="orderDetail_common">
					<div class="textSmall textGrey textBottom">优惠</div>
					<div>优惠已优惠<span id="favorablePrice" class="textRed">3元</span></div>
				</div>
				<div class="orderDetail_common">
					<div class="textSmall textGrey textBottom restaurantName">0000</div>
					<ul id="orderDet" class="res_order">
						<li><span class="textLeft">麻辣小龙虾</span><span>X1</span><span class="textRight">￥68.00</span></li>
						<li><span class="textLeft">麻辣小龙虾</span><span>X1</span><span class="textRight">￥68.00</span></li>
					</ul>
				</div>
				<div class="orderDetail_common">
					<div class="textRight">合计：<span>￥<span class="factPrice">00</span></span></div>
				</div>
			</div>
		</section>

	</div>
	
</body>

<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/httpUnit.js"></script>
<script type="text/javascript">
	findFoodOrderDetail();
	//订单详情
	function findFoodOrderDetail(){
		var Request = new Object();
		Request = GetRequest();
		
		var id = Request['id'];
		
		var obj = JSON.stringify({
			"id": id
		});
		
		httpHelperpost("/api/foodOrders/findFoodOrderDetail", obj, function(isSuccess, data) {
        	if (isSuccess == true) {
        	    var response = data.responseText;
        	    var value = JSON.parse(response);
    				
   				// console.log(response);
   				
        	    if(value.code == 0){
        	     	console.log("查询成功");
        	     	var status = "";
   					var orderHtml = "";
   					
   					if(value.data.status == 0){
   						status="待付款";
   					}else if(value.data.status == 1){
                		status="待发货";
                	}else if(value.data.status == 2){
                		status="派送中(待使用)";
                	}else if(value.data.status == 3){
                		status="待评价(已完成)";
                	}else if(value.data.status == 4){
                		status="退款/售后";
                	}else if(value.data.status == 5){
                		status="已取消";
                	}
	
                	$(".userName").text(value.data.userName);
                	$(".status").text(status);
                	$(".remark").text(textisNull(value.data.remark));
                	$(".foodListNumber").text(value.data.foodList.length);
        	    	$(".restaurantName").text(value.data.restaurantName);
        	    	$("#favorablePrice").text(value.data.favorablePrice+"元");
        	    	$(".deliveryName").text(textisNull(value.data.deliveryName));
	
        	    	for(var i=0;i<value.data.foodList.length;i++){
        	    		orderHtml+="<li><span class='textLeft'>"+value.data.foodList[i].name+"</span><span>X"+value.data.foodList[i].buyNum+"</span><span class='textRight'>￥"+value.data.foodList[i].price+"</span></li>"
        	    	}

        	   		$(".factPrice").text(value.data.factPrice);
        	    	$("#orderDet").html(orderHtml);
        	    	
        	    	// showProgress(value.data.orderNumber);
        	    	//展示订单进度
        	    	var html = "<ul id='showProgressUl' class='showNo'>";
        	    	var deliveryLen = value.data.deliveryProgress.length;
   					for(var i=0;i<deliveryLen;i++){
   						html+="<li class='textBottom'><span>"+value.data.deliveryProgress[i].progress+"</span><span class='textRight'>"+allDateTime(value.data.deliveryProgress[i].progressTime,0)+"</span><div>"+textisNull(value.data.deliveryProgress[i].progressRemark)+"</div></li>"
   					}
   					html +="</ul>";
   					$("#showProgress").append(html);
   					if(value.data.deliveryProgress==""||value.data.deliveryProgress==null){
   						$("#showProgress").css("display","none");
   					}
   					$("#lastState_time").text(allDateTime(value.data.deliveryProgress[deliveryLen-1].progressTime,1));
   					$(".lastState_name").text(value.data.deliveryProgress[deliveryLen-1].progress);

        	    	// $("#lastEvaluate").html("<span class='textGrey'>近30天第一次下单&nbsp.&nbsp</span><span class='textBlue' onclick=lastEvaluate('"+value.data.userAddressInfo.userId+"')>用户上次评价</span>");
        	    	// lastEvaluate(value.data.userAddressInfo.userId);
        	    }else if(value.code==401){
        	    	alert(value.message);
        	    	window.location.href='./login.html';
        	    }else{
        	    	alert(value.message);
        	     	console.log("查询失败");
        	    }
        	}else {}
    	});
	}

	//点击展示进度
	function showProgressCl(){
		if($("#showProgressUl").text()==""){
			alert("当前进度为空");
		}
		var show = $("#showProgressUl");
		if(show.css("display")=="none"){
			show.css("display","block");
		}else{
			show.css("display","none");
		}
	}

	//内容判空函数
	function textisNull(value){
		if(value==null||value==undefined){
			value="";
		}
		return value;
	}

	//统一修改日期格式
	function allDateTime(date,index){
		var newDate = new Date(date);
		var year = newDate.getFullYear();
		var month = newDate.getMonth()+1;
		var day = newDate.getDay();
		var hour = newDate.getHours();
		var minute = newDate.getMinutes();

		if(index==0){
			return year+"-"+month+"-"+day+" "+hour+":"+minute;
		}else if(index==1){
			return hour+":"+minute;
		}
		
	}

	//点击返回到订单列表
	function disOrder(){
		var Request = GetRequest();
    	var status = Request['status'];
    	window.location.href="./order.html?status="+status;
	}

	//获取url中"?"符后的字串
	function GetRequest() {
	    var url = location.search; //获取url中"?"符后的字串   
	    
	    var theRequest = new Object();
	    if (url.indexOf("?") != -1) {
	      var str = url.substr(1);
	      
	      strs = str.split("&");
	      
	      for (var i = 0; i < strs.length; i++) {
	        
	        theRequest[strs[i].split("=")[0]] = strs[i]
	            .split("=")[1];
	      }
	    }
	    return theRequest;
	}
</script>
</html>